package com.bifang.module.file.gateway.controller;

import com.bifang.module.base.common.vo.tree.TreeRetVO;
import com.bifang.module.file.common.vo.FileClassTreeVO;
import com.bifang.module.file.common.vo.fileCollect.FileCollectTreeVO;
import com.bifang.module.file.core.biz.FileCollectIntegration;
import com.bifang.module.file.common.vo.fileCollect.FileCollectVO;
import com.bifang.module.file.common.vo.fileCollect.FileCollectKeyVO;
import com.bifang.module.file.common.vo.fileCollect.FileCollectQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

/**
 * 文件归集管理网关
 *
 * @author shun
 * @since 2023-03-22
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "文件归集管理", description = "文件归集管理")
public class FileCollectController {

    @Autowired
    public FileCollectIntegration fileCollectIntegration;

    @Operation(summary = "文件归集管理分页查询",description = "文件归集管理分页查询")
    @PostMapping(value = "/fileCollect0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileCollectVO>> getList(@RequestBody @Validated FileCollectQueryVO vo) {
        return AppResponse.successData(fileCollectIntegration.getList(vo));
    }

    @Operation(summary = "文件归集管理根据主键查询详情",description = "文件归集管理根据主键查询详情")
    @PostMapping(value = "/fileCollect0002", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectVO> getById(@RequestBody @Validated FileCollectKeyVO vo) {
        return AppResponse.successData(fileCollectIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件归集管理新增",description = "文件归集管理新增")
    @PostMapping(value = "/fileCollect0004", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectVO> add(@RequestBody @Validated(value = {Validators.Add.class}) FileCollectVO vo) {
        return AppResponse.successData(fileCollectIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件归集管理修改",description = "文件归集管理修改")
    @PostMapping(value = "/fileCollect0005", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) FileCollectVO vo) {
        return AppResponse.successData(fileCollectIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件归集管理删除",description = "文件归集管理删除")
    @PostMapping(value = "/fileCollect0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated FileCollectKeyVO vo) {
        fileCollectIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "获取归集分类树",description = "获取归集分类树")
    @PostMapping(value = "/fileCollect0007", produces = "application/json;charset=UTF-8")
    public AppResponse<TreeRetVO> getFileCollectTree(@RequestBody @Validated FileCollectTreeVO vo) {
        return AppResponse.successData(fileCollectIntegration.getFileCollectTree(vo));
    }

}
